#!/bin/bash
yum  -y install http://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
yum -y install postgresql95-server
#yum install postgresql95-client
/usr/pgsql-9.5/bin/postgresql95-setup initdb

#psql -c "ALTER USER vagrant SUPERUSER"
echo *****start postgresql*****
systemctl enable postgresql-9.5.service
systemctl start postgresql-9.5.service

su - postgres <<EOF
echo *****create user vagrant*****
psql -c "CREATE USER vagrant WITH PASSWORD 'vagrant'"
psql -c "ALTER USER vagrant SUPERUSER"
echo *****create user vagrant*****
sed -i "/^host.*::1/s/host/#host/"  ~/9.5/data/pg_hba.conf
sed -i "/^host.*127.0.0.1/s/127.0.0.1\/32.*/0.0.0.0\/0    password/"  ~/9.5/data/pg_hba.conf
sed -i "/^#listen_addresses = 'localhost'/s/#listen_addresses.*=.*'localhost'/listen_addresses = '*'/"  ~/9.5/data/postgresql.conf
EOF

systemctl restart postgresql-9.5.service
#yum install 